package config

import (
	"sync"
	"time"
)

var Conf *Config
var once sync.Once

func C() *Config {
	once.Do(func() {
		Conf = &Config{}
	})
	return Conf
}

type Config struct {
	App     string
	Version string

	HTTPServer *HTTPServerConfig

	Engine  *EngineConfig
	SSH     *SSHConfig
	CLI     *CLIConfig
	Netconf *NetconfConfig
	GNMI    *GNMIConfig

	ExecDB *SQLDBConfig

	Log *LogConfig
}

type HTTPServerConfig struct {
	Host           string
	Port           int16
	Mode           string
	LogLevel       string
	ReadTimeoutMs  time.Duration
	WriteTimeoutMs time.Duration
}

type EngineConfig struct {
	MaxChannelCount   uint
	MaxChannelQueSize int
}

type SSHConfig struct {
	ConnTimeoutMs  time.Duration
	ReadTimeoutMs  time.Duration
	WriteTimeoutMs time.Duration
}

type CLIConfig struct {
	QueueTimeoutMs time.Duration
}

type NetconfConfig struct {
	QueueTimeoutMs time.Duration
}

type GNMIConfig struct {
	QueueTimeoutMs time.Duration
}

// SQLDBConfig sql数据库配置结构
type SQLDBConfig struct {
	Dsn string // main channel

	MaxIdleTime int
	MaxLifeTime int
	MaxIdleConn int
	MaxOpenConn int

	LogLevel string
}

// LogConfig log
type LogConfig struct {
	FilePath   string
	MaxAgeHour int
}
